<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */

fconv::init( );

/**
 * Smarty area_units modifier plugin for commercial.su
 *
 * Type:     modifier<br>
 * Name:     area_units<br>
 * Purpose:  format areas via fconv<br>
 * Input:<br>
 *         - value: area value
 *         - src: source type (can be 1 for metric or 2 for british-american [foots/yards])
 *         - dest: destination type (see $src)
 * @author   Alex <qfox@ya.ru> Yaroshevich
 * @param numeric
 * @return string|void
 * @uses fconv
 */
function smarty_modifier_area_units( $value, $type = null, $short = true )
{
	$z = fconv::areaunits( $type, !$short );
	
	if( strpos( $z, 'sq ' ) === 0 ) $z = gettext( str_replace( 'sq ', '', $z ) )."<sup><small>2</small></sup>";
	
	return ( $short )
		? $z
		: ngettext( $z, $z.'s', $value );
}

/* vim: set expandtab: */

?>